<?php if (!isset($v_sval)) exit; ?>
<?php
$v_offset = (isset($_REQUEST["hdn_offset"])) ? $_REQUEST["hdn_offset"] : 0;
$v_num_row = (isset($_REQUEST["hdn_num_row"])) ? $_REQUEST["hdn_num_row"] : SYS_ITEMS_PER_PAGE;

$v_album_title = (isset($_REQUEST["txt_album_title"])) ? $_REQUEST["txt_album_title"] : 0;
$v_album_detail = (isset($_REQUEST["txt_album_detail"])) ? $_REQUEST["txt_album_detail"] : 0;
$v_account_id = (isset($_REQUEST["txt_account_id"])) ? $_REQUEST["txt_account_id"] : 0;
		
$v_where_clause = " AND ACCOUNT_ID = '".$user_id."'";

$edit_album_id = (isset($_REQUEST["hdn_album_id"])) ? $_REQUEST["hdn_album_id"] : 0;
$album_title = '';
$album_detail = '';

if ( $edit_album_id ){

	if ( $user_id == getOwnerAlbum($edit_album_id) ){
		$rs = getSingerAlbum ($edit_album_id);
		if ($arr = mysql_fetch_assoc($rs)){
			$album_title = $arr['ALBUM_TITLE'];
			$album_detail = $arr['ALBUM_DETAIL'];
		}
	}
	else{
		redir('?a=ACC&acc=USER&user=ALBU');
	}
}

$rs_all_album = getAllAlbum($v_where_clause,$v_offset ,$v_num_row);
$v_dsp_album_list = '';
$v_inc = 1;

while ( $arr_album = mysql_fetch_array($rs_all_album,MYSQL_NUM)){
	$v_dsp_image_in_album = '';
	$v_album_id=$arr_album["0"];
	$v_album_title=$arr_album["1"];
	$v_album_detail=$arr_album["2"];
	$v_account_id=$arr_album["3"];	

	if ( countAll(' AND ALBUM_ID = "'.$v_album_id.'"','TB_IMAGE') )
		$v_dsp_image_in_album .= '<br/><br/>
		<div class="image_carousel" style="width:700px;padding-left:0">
			<div id="album_'.$v_album_id.'">
				'.generateAlbumSlider($v_album_id).'
			</div>
			<div class="clearfix"></div>
			<a class="prev" id="album_'.$v_album_id.'_prev" href="#"><span>prev</span></a>
			<a class="next" id="album_'.$v_album_id.'_next" href="#"><span>next</span></a>
			<div class="slider_page" id="album_'.$v_album_id.'_pag"></div>
		</div>
		<script type="text/javascript">
			head.ready(function() {
				$("#album_'.$v_album_id.'").carouFredSel({
					circular: true,
					infinite: false,
					auto 	: true,
					scroll	: {
						items	: "page",
						fx          : "directscroll",
        				easing      : "quadratic",
				        duration    : 1000
					},
					pauseOnHover : true,
					prev	: {	
						button	: "#album_'.$v_album_id.'_prev",
						key		: "left"
					},
					next	: { 
						button	: "#album_'.$v_album_id.'_next",
						key		: "right"
					},
					pagination	: "#album_'.$v_album_id.'_pag"
				});
			});
		</script>
		';
	$v_dsp_album_list .='
	<div>
		<span class="title" style="padding-right:50px">'.$v_album_title.'</span>
	</div>
	<div class="event_content">		
		<div style="padding-top:10px">'.$v_album_detail.'</div>
		<a class="button left" href="?a=ACC&acc=USER&user=ALBU&albu=U&hdn_album_id='.$v_album_id.'">
					'._IMAGE_UPLOAD_IMAGE.'</a>
		<a class="button left" href="?a=ACC&acc=USER&user=ALBU&hdn_album_id='.$v_album_id.'#edit_content">
					'._IMAGE_EDIT_IMAGE.'</a>
		<a class="button left" onclick=\'if(!confirm("Toàn bộ ảnh trong album sẽ bị xóa! Bạn có chắc chắn không ?")){return false;}\' href="?a=ACC&acc=USER&user=ALBU&albu=D&hdn_album_id='.$v_album_id.'">
					'._IMAGE_DELETE_IMAGE.'</a>'
		.$v_dsp_image_in_album.'
	</div>';	
	$v_inc++;

}

$v_number_of_all_result = countAll($v_where_clause,'TB_ALBUM');
?>
